CREATE TABLE [dbo].[Transactions]
(
[Id] [bigint] NOT NULL IDENTITY(1, 1),
[TransactionCode] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[TransactionTypeId] [int] NULL,
[Amount] [decimal] (18, 0) NULL,
[Status] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[TimeFinalised] [datetime] NULL,
[TimeInitiated] [datetime] NULL,
[TimeProcessed] [datetime] NULL,
[AuthorisationId] [int] NULL,
[ParentId] [int] NULL,
[LastUpdate] [datetime] NULL,
[ExpiryDate] [datetime] NULL,
[RecipientId] [int] NULL,
[SenderId] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Transactions] ADD CONSTRAINT [PK_Transactions] PRIMARY KEY CLUSTERED  ([Id]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Transactions] ADD CONSTRAINT [FK_Transactions_Account] FOREIGN KEY ([AuthorisationId]) REFERENCES [dbo].[Accounts] ([Id])
GO
ALTER TABLE [dbo].[Transactions] ADD CONSTRAINT [FK_Transactions_Account2] FOREIGN KEY ([RecipientId]) REFERENCES [dbo].[Accounts] ([Id])
GO
ALTER TABLE [dbo].[Transactions] ADD CONSTRAINT [FK_Transactions_Account1] FOREIGN KEY ([SenderId]) REFERENCES [dbo].[Accounts] ([Id])
GO
ALTER TABLE [dbo].[Transactions] ADD CONSTRAINT [FK_Transactions_TransactionTypes1] FOREIGN KEY ([TransactionTypeId]) REFERENCES [dbo].[TransactionTypes] ([Id])
GO
